import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'
// 引入去全局的样式
import './style/global.css'
// 引入icon图标样式
import './assets/fonts/iconfont.css'
// 引入第三方库tree-grid
import ZkTable from 'vue-table-with-tree-grid'
// 引入富文本编辑器
import VueQuillEditor from 'vue-quill-editor'
// 引入富文本编辑器相关样式
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'

// 引入axios
import axios from 'axios'
// 配置基本登陆地址
axios.defaults.baseURL = 'http://liufusong.top:8888/api/private/v1/'
// 配置请求拦截器
axios.interceptors.request.use(config => {
  config.headers.Authorization = sessionStorage.getItem('token')
  return config
})
// 配置响应拦截器
axios.interceptors.response.use(res => {
  return res.data
})
Vue.prototype.$axios = axios

Vue.config.productionTip = false
// 注册tree-grid这个组件
Vue.component('tree-grid', ZkTable)
// 定义一个全局的时间过滤器
Vue.filter('formDate', (time) => {
  const date = new Date(time * 1000)
  const y = date.getFullYear()
  const m = date.getMonth()
  const d = date.getDate()
  return `${y}-${m}-${d}`
})
Vue.use(VueQuillEditor)

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
